<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>您好Springboot</title>
	<script src="../js/jquery-3.4.1.min.js"></script>
	<style type="text/css">
		table {
			border-collapse: collapse;
		}
	</style>
	<script type="text/javascript">
		
		$(function(){
			// alert("ppppp");
			let url = "/findAllUsers1111";
			let params = {id: 43, name: "tomcat"};	//"id = 1&name = tomcat";
			$.get(url, params, function(result){
				// console.log(result);
				for(let user of result){
					let id = user.id;
					let name = user.name;
					let age = user.age;
					let sex = user.sex;
					let tr = "<tr align='center'><td>"+id+"</td><td>"+name+"</td><td>"+age+"</td><td>"+sex+"</td></tr>"
					$("#table1").append(tr);
				}
				
				/* 循环1: for循环遍历所有的变量 
					for(let i = 0; i < result.length; i++){
						let user = result[i];
					}*/
				/* 循环2: 
					for(let index in result){
						let user = result[index];
					} 	
				*/
				/* 循环3: 
					for(let user of result){
						let id = user.id;
						...
					} */
			})

			$.ajax({
				url: "/findAllUsers",
				method: "get",
				params: {id: 43, name: "tomcat"},
				success: function (result) {
					doIndexUI(result);
				}
			})

			function doIndexUI(result) {
				for(let user of result){
					let id = user.id;
					let name = user.name;
					let age = user.age;
					let sex = user.sex;
					let tr = "<tr align='center'><td>"+id+"</td><td>"+name+"</td><td>"+age+"</td><td>"+sex+"</td></tr>"
					$("#table1").append(tr);
				}
			}
		})
		
	</script>
</head>
<body>
	<table border="1px" width="65%" align="center" id="table1">
		<tr>
			<td colspan="6" align="center"><h3>学生信息</h3></td>
		</tr>
		<tr>
			<th>编号</th>
			<th>姓名</th>
			<th>年龄</th>
			<th>性别</th>
			<!-- <th></th> -->
		</tr>
		


	</table>
	<script type="javascript">

	</script>
</body>
</html>